function trace<T>(data:T):T{
    console.log("进行记录-",data)
    return data;
}
var num1=1
var num2=2
var num3=trace(num1)+trace(num2)

var str1="Hello"
var str2="TypeScript"

trace<string>(str1)

function first<T>(array:T[]):T{
    if(array.length>0){
        return array[0]
    }else{
        throw new Error("数组为空")
    }
}

var array1=[1,2,3]
var array2=["a","b","c"]
console.log(first(array1))
console.log(first(array2))

class List<T>{
    elems:Array<T>
    constructor() {
    this.elems=[]
    }
    add(obj:T){
        this.elems.push(obj)
    }
}

var list=new List<number>();
list.add(1)
list.add(2)
console.log(list)

interface Area<T>{
    area(o:T):number;
}

interface  Areaq<T extends number>{
    area(a:T):number;
}
